//
//  DLMapModeViewController.m
//  DLSport
//
//  Created by DongL on 2017/4/26.
//  Copyright © 2017年 DongL. All rights reserved.
//

#import "DLMapModeViewController.h"

@interface DLMapModeViewController ()

//选中地图类型block
@property (nonatomic, copy) void(^selectBlock)(DLMapType mapType);
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *MapModeBtns;

@end

@implementation DLMapModeViewController

- (instancetype)initWithselectBlock:(void(^)(DLMapType maptype))selectBlock {
    
    self = [super init];
    if (self) {
        
        self.selectBlock = selectBlock;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *btn = self.MapModeBtns[self.mapType];
    btn.selected = YES;
}

- (IBAction)clickMapModeBtn:(UIButton *)sender {
    for (UIButton *btn in self.MapModeBtns) {
        
        //判断当前选中状态
        if (!sender.selected) {
            
            if (self.selectBlock) {
                
                //执行选中Block  传递数据给trackVc
                self.selectBlock(sender.tag);
            }
        }
        //设置选中
        btn.selected = (btn == sender) ? YES : NO;
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
